package com.coocaa.ops.admin.v1.upload.ftp.model;

import lombok.Data;

/**
 * @author bijiahao
 * @date : 2019/2/14.
 * @description
 */
@Data
public class ProgressMonitor {
    /**
     * 总的文件大小
     */
    private long total;
    /**
     * 完成的文件大小
     */
    private long completed;
    /**
     * 进度（0-100）
     */
    private int progress;


    public ProgressMonitor() {
        this.total = 0;
        this.completed = 0;
        this.progress = 0;
    }

    /**
     * 更新完成进度
     *
     * @param completed
     */
    public void updateCompleted(long completed) {
        this.completed += completed;
        if (this.total > 0L) {
            this.progress = (int) (this.completed * 100L / this.total);
            if (this.progress > 100) {
                this.progress = 100;
            }
        }
    }
}
